import axios,{get,post,put,patch,delet} from './http'
//添加
export const addUser = async function (url, d, callback) {
    const data = await axios.post(url,d)
    await callback(data)
}


export async function getDataList(state,url,params) {
    state.loading = true
    const res = await axios.get(url,params)
    state.loading = false
    state.dataList = res.data
    if(res.code === 200){
        ElMessage({type:'success',message:res.msg})
    }else{
        ElMessage({type:'error',message:res.msg})
    }
}


//删除
export const del = async function(url,params,callback){
    //params {parames:{id:3,name:'李四'}}
    const data = await axios.delete(url,params)
    await callback(data)
}

//显示 url,data
export const getUsers = async function (url, data, callback) {
    const res = await axios.get(url,data)
    await callback(res)
}

//修改
export const update = async function (url, data, callback) {
    const res = await axios.put(url,data)
    await callback(res)
}

